import 'package:iirjdart/chebyshev_1.dart';
import 'package:sleep/single/filter/base_filter.dart';
import 'package:sleep/config.dart';

class DigitalFilter extends BaseFliter {
  final double startFrequency;
  final double endFrequency;
  late ChebyshevI butterworth;

  DigitalFilter(this.startFrequency, this.endFrequency) {
    butterworth = ChebyshevI()
      ..bandPass(3, 1000 / kMin, (endFrequency + startFrequency) / 2,
          (endFrequency - startFrequency), 0.01);
  }
  @override
  List<double> fliter(List<double> data) {
    return data.map((e) => butterworth.filter(e)).toList();
  }
}
